Skip to content

ENH: Deprecate non-keyword arguments for MultiIndex.set_levels #41589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 26, 2021

Conversation

01-vyom
Copy link
Contributor

@01-vyom 01-vyom commented May 20, 2021

@jbrockmendel
Copy link
Member

Looks like you need to tinker with stacklevels in some of the warnings

@simonjayhawkins simonjayhawkins added Deprecate Functionality to remove in pandas MultiIndex labels May 21, 2021
@01-vyom
Copy link
Contributor Author

01-vyom commented May 23, 2021

Made all the changes.

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, thanks!

@MarcoGorelli MarcoGorelli added this to the 1.3 milestone May 23, 2021
@MarcoGorelli MarcoGorelli self-requested a review May 23, 2021 17:28
Copy link
Member

@jbrockmendel jbrockmendel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 test failure looks like it might be relevant, will take a closer look later

________ TestSeriesGetitemScalars.test_getitem_keyerror_with_int64index ________
[gw1] linux -- Python 3.8.10 /usr/share/miniconda/envs/pandas-dev/bin/python

self = <pandas.tests.series.indexing.test_getitem.TestSeriesGetitemScalars object at 0x7f8b6e332640>

    def test_getitem_keyerror_with_int64index(self):
        ser = Series(np.random.randn(6), index=[0, 0, 1, 1, 2, 2])
    
        with pytest.raises(KeyError, match=r"^5$"):
            ser[5]
    
        with pytest.raises(KeyError, match=r"^'c'$"):
>           ser["c"]

pandas/tests/series/indexing/test_getitem.py:92: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pandas/core/series.py:945: in __getitem__
    return self._get_value(key)
pandas/core/series.py:1054: in _get_value
    loc = self.index.get_loc(label)
pandas/core/indexes/base.py:3356: in get_loc
    return self._engine.get_loc(casted_key)
pandas/_libs/index.pyx:76: in pandas._libs.index.IndexEngine.get_loc
    cpdef get_loc(self, object val):
pandas/_libs/index.pyx:103: in pandas._libs.index.IndexEngine.get_loc
    return self._get_loc_duplicates(val)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   left = values.searchsorted(val, side='left')
E   FutureWarning: Promotion of numbers and bools to strings is deprecated. In the future, code such as `np.concatenate((['string'], [0]))` will raise an error, while `np.asarray(['string', 0])` will return an array with `dtype=object`.  To avoid the warning while retaining a string result use `dtype='U'` (or 'S').  To get an array of Python objects use `dtype=object`. (Warning added in NumPy 1.21)

EDIT

maybe not actually, been seeing that error in a few other PRs

@jbrockmendel
Copy link
Member

failure is unrelated; thats the build that tests against numpy's dev branch and raises if we encounter and FutureWarnings, which we now do all over

@MarcoGorelli MarcoGorelli self-requested a review May 25, 2021 19:42
@simonjayhawkins simonjayhawkins merged commit 4944939 into pandas-dev:master May 26, 2021
@simonjayhawkins
Copy link
Member

Thanks @01-vyom

@01-vyom 01-vyom deleted the pandas-set_levels-41485 branch May 29, 2021 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas MultiIndex
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants